package com.longwang.entity;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.validation.constraints.NotEmpty;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;

/**
 * 用户实体
 * @author LongWang
 *
 */
@Entity
@Table(name="t_user")
@JsonIgnoreProperties(value={"hibernateLazyInitializer","handler","fieldHandler"})
public class User {

	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	private Integer userId; // 用户Id
	
	@NotEmpty(message="openID不能为空！")
	@Column(length=200)
	private String openId;  // openID
	
	@NotEmpty(message="昵称不能为空！")
	@Column(length=200)
	private String nickname;  // 昵称
	
	@Column(length=200)
	private String headPortrait;  // 头像
	
	@Column(length=50)
	private String sex;  // 性别
	
	private Date registrationDate;  // 注册日期
	
	private Date latelyLoginTime;  // 最近登录时间

	public Integer getUserId() {
		return userId;
	}

	public void setUserId(Integer userId) {
		this.userId = userId;
	}

	public String getOpenId() {
		return openId;
	}

	public void setOpenId(String openId) {
		this.openId = openId;
	}

	public String getNickname() {
		return nickname;
	}

	public void setNickname(String nickname) {
		this.nickname = nickname;
	}

	public String getHeadPortrait() {
		return headPortrait;
	}

	public void setHeadPortrait(String headPortrait) {
		this.headPortrait = headPortrait;
	}

	public String getSex() {
		return sex;
	}

	public void setSex(String sex) {
		this.sex = sex;
	}

	@JsonSerialize(using=CustomDateTimeSerializer.class)
	public Date getRegistrationDate() {
		return registrationDate;
	}

	public void setRegistrationDate(Date registrationDate) {
		this.registrationDate = registrationDate;
	}

	@JsonSerialize(using=CustomDateTimeSerializer.class)
	public Date getLatelyLoginTime() {
		return latelyLoginTime;
	}

	public void setLatelyLoginTime(Date latelyLoginTime) {
		this.latelyLoginTime = latelyLoginTime;
	}
	
	
}
